package xmlexample;

/*
 * Videoteca_stile.java
 *
 * Created on 19 aprile 2004, 22.24
 */
import net.ermannofranco.xml.style.*;

/**
 *
 * @author  ermanno
 */
public class Videoteca_stile {
	private static final String resourcesPath = "/media/TRETRE/versioncontrol/xmlfactory/Esempi/resources/";
	private static final String templateName = "Videoteca_skeleton_xsl.html";
	private static final String templatePathName = resourcesPath + templateName;

  private final Stylesheet st;
      
  /** Creates a new instance of Videoteca_stile */
  public Videoteca_stile() {
    Template te;
    ApplyTemplates at;
    If iff;

    st=new Stylesheet();

    (te=st.addTemplate("/"))
    .loadCDATAFile(templatePathName,1,9);
    (at=te.addApplyTemplates("//video"))
    .addSort("@titolo")
    ;
    te.loadCDATAFile(templatePathName,31);

    (te=st.addTemplate("video"))
    .loadCDATAFile(templatePathName,9,13);
    te.addValueOf("@titolo");
    te.loadCDATALinesFromFile(templatePathName,13,1);
    te.addCDATA("genere: ");
    te.addValueOf("@genere");
    te.addCDATA("; regista: ");
    te.addValueOf("@regista");
    te.addCDATA("; supporto: ");
    te.addValueOf("@supporto");
    te.addCDATA("; copie disponibili: ");
    te.addValueOf("@disponibili");
    te.loadCDATALinesFromFile(templatePathName,14,2);
    te.addAttribute("src")
    .addValueOf("@locandina");
    te.loadCDATALinesFromFile(templatePathName,16,4);
    te.addValueOf("trama");
    te.loadCDATALinesFromFile(templatePathName,20,2);
    te.addApplyTemplates("attore");
    te.addApplyTemplates("musiche");
    te.loadCDATALinesFromFile(templatePathName,30,1);

    (te=st.addTemplate("attore"))
    .loadCDATALinesFromFile(templatePathName,22,2);
    te.addIf("@principale='true'")
    .addValueOf("@nome")
    ;
    te.loadCDATALinesFromFile(templatePathName,24,2);

    (te=st.addTemplate("musiche"))
    .loadCDATALinesFromFile(templatePathName,26,2);
    te.addCDATA("Musica: ");
    (iff=te.addIf("@autore"))
    .addValueOf("@autore")
    ;
    iff.addCDATA("; ");
    te.addValueOf(".");
    te.loadCDATALinesFromFile(templatePathName,28,2);




//    st.save("../generati/"+getClass().getName());
  }

  public String toString()  {
    return st.toString();
  }
}
